package com.zkthink.ceres.applet.product.controller;

import com.zkthink.base.R;
import com.zkthink.ceres.applet.common.domin.vo.PageDateTypeIdVo;
import com.zkthink.ceres.applet.product.domain.vo.InsertPrivateProductOrServerVo;
import com.zkthink.ceres.applet.product.domain.vo.InsertPublicOrServerVo;
import com.zkthink.ceres.applet.product.service.AppletProductService;
import com.zkthink.ceres.applet.server.domain.vo.FindServerDetailVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author cmz
 * @Date 2024-04-28 14:00
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/applet/ceresProduct")
@Api(value = "pcProduct", tags = "产品信息")
public class PcProductController {
    @Autowired
    private AppletProductService appletProductService;

    @ApiOperation(value = "分页查询产品信息", notes = "分页查询产品信息")
    @PostMapping(value = "/findByPage")
    public R findAll(@RequestBody PageDateTypeIdVo pageDateTypeIdVo) {
        return appletProductService.findByPage(pageDateTypeIdVo);
    }

    @ApiOperation(value = "查询服务/产品信息详情", notes = "查询服务/产品信息详情")
    @PostMapping(value = "/detail")
    public R serverDetail(@RequestBody FindServerDetailVo findServerDetailVo) {
        return appletProductService.detail(findServerDetailVo);
    }

    @ApiOperation(value = "添加独有产品/服务信息", notes = "添加独有产品/服务信息")
    @PostMapping(value = "/insertPrivateProductOrServer")
    public R insertPrivateProductOrServer(@RequestBody InsertPrivateProductOrServerVo insertPrivateProductOrServerVo) {
        return appletProductService.insertPrivateProductOrServer(insertPrivateProductOrServerVo);
    }

    @ApiOperation(value = "根据type查询服务、产品分类数据", notes = "根据type查询服务、产品分类数据")
    @GetMapping(value = "/findCateGoryByType/{type}")
    public R findCateGoryByType(@PathVariable Integer type) {
        return appletProductService.findCateGoryByType(type);
    }

    @ApiOperation(value = "根据type查询服务、产品", notes = "根据type查询服务、产品")
    @GetMapping(value = "/findServerProductByType/{type}")
    public R findServerProductByType(@PathVariable Integer type) {
        return appletProductService.findServerProductByType(type);
    }

    @ApiOperation(value = "根据name查询服务、产品", notes = "根据name查询服务、产品")
    @GetMapping(value = "/findServerProductByName/{name}")
    public R findServerProductByType(@PathVariable String name) {
        return appletProductService.findServerProductByName(name);
    }

    @ApiOperation(value = "添加公有产品/服务信息", notes = "添加公有产品/服务信息")
    @PostMapping(value = "/insertPublicProductOrServer")
    public R insertPublicProductOrServer(@RequestBody InsertPublicOrServerVo insertPublicOrServerVo) {
        return appletProductService.insertPublicProductOrServer(insertPublicOrServerVo);
    }

    @ApiOperation(value = "根据type查询当前用户的服务、产品", notes = "根据type查询服务、产品")
    @GetMapping(value = "/findMyServerProductByType/{type}")
    public R findMyServerProductByType(@PathVariable Integer type) {
        return appletProductService.findMyServerProductByType(type);
    }

    @ApiOperation(value = "根据type删除当前用户的服务、产品", notes = "根据type查询服务、产品")
    @GetMapping(value = "/updateMyServerProductByType/{type}/{id}")
    public R updateMyServerProductByType(@PathVariable Integer type,@PathVariable Long id) {
        return appletProductService.updateMyServerProductByType(type,id);
    }
    
}
